package com.magiccompass.alipay.barcode.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "TS_USER_INFO")
@DynamicUpdate(value= true)
public class UserInfo {
	@Id
	@Column(name = "ID")
	@GeneratedValue
	private Integer id;
	
	@Column(name = "user_name", length=256, nullable=false)
    private String userName;
	
	@Column(name = "password",length=45, nullable=false)
	private String password;
	
	@Column(name = "role_id", nullable=false)
	private Integer roleId;
	
	@Column(name = "del_flag")
	private String delFlag = "F";
	
	@OneToOne(cascade=CascadeType.REFRESH,fetch = FetchType.EAGER)
	@JoinColumn(name="merchant_id", nullable=true)
	private MerchantInfo merchant;
	
	@OneToOne(cascade=CascadeType.REFRESH,fetch = FetchType.EAGER)
	@JoinTable(name="td_user_merchant_group",
			joinColumns = @JoinColumn(name = "user_id"), 
			inverseJoinColumns = @JoinColumn(name = "merchant_group_id"))
	private MerchantGroup merchantGroup;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}

	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	public MerchantInfo getMerchant() {
		return merchant;
	}

	public void setMerchant(MerchantInfo merchant) {
		this.merchant = merchant;
	}

	public MerchantGroup getMerchantGroup() {
		return merchantGroup;
	}

	public void setMerchantGroup(MerchantGroup merchantGroup) {
		this.merchantGroup = merchantGroup;
	}
}